﻿<Window x:Class="Client.Windows.NewWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:Client.Converters"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Height="650" Width="800"
        Background="{StaticResource NewPageBackground}" 
        WindowStartupLocation="CenterScreen">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="pack://application:,,,/Client;component/Resources/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <converters:TitleConverter x:Key="titleConverter"/>
            <converters:ImageConverter x:Key="imageConverter"/>
        </ResourceDictionary>
    </Window.Resources>

    <Window.Title>
        <Binding Path="CurrentPageViewModel.CurrentPageViewModel.Name" Converter="{StaticResource titleConverter}"/>
    </Window.Title>
    <Grid Margin="1,10,1,5">

        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Grid.RowSpan="2" Name="pctr">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Border Grid.Column="0" Grid.RowSpan="3" Grid.Row="0" Margin="5,5,5,5"
                     BorderBrush="{StaticResource BaseColor}" BorderThickness="6,6,6,6"
                    CornerRadius="10,10,10,10"
                    VerticalAlignment="Center" MaxHeight="200" MaxWidth="150">
                <Image Source="{Binding CurrentPageViewModel.ObjectToPersist.Slika, Converter={StaticResource imageConverter}}" />
            </Border>


            <Button Grid.Column="2" Grid.Row="1" Content="Traži sliku..." Height="32" VerticalAlignment="Stretch" HorizontalAlignment="Right" Margin="10,10,10,0" MinWidth="100" MaxWidth="200" 
                    Command="{Binding CurrentPageViewModel.CurrentPageViewModel.OpenFileDialogCommand}" 
                    CommandParameter="{Binding CurrentPageViewModel.ObjectToPersist}"/>

            <TextBox Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Stretch" Margin="10,5,10,5" IsEnabled="False" 
                     Text="{Binding CurrentPageViewModel.CurrentPageViewModel.ImagePath}"/>
        </Grid>


        <ContentControl Grid.Row="2" Grid.RowSpan="5" HorizontalContentAlignment="Stretch" Content="{Binding CurrentPageViewModel}" Margin="10,10,5,10"/>
        <!--<ContentControl Grid.Row="2" Grid.RowSpan="5" Content="{Binding CurrentPageViewModel.CurrentPageViewModel}" Margin="10,10,5,10"/>-->
        <Grid Grid.Row="7">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>


            <Button VerticalAlignment="Stretch" Margin="2" Grid.ColumnSpan="3" Width="Auto" Grid.Row="7"
                    Command="{Binding CurrentPageViewModel.CurrentPageViewModel.SubmitCommand}" 
                    CommandParameter="{Binding CurrentPageViewModel.ObjectToPersist}" 
                    Content="Snimi">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <i:InvokeCommandAction Command="{Binding CurrentPageViewModel.CurrentPageViewModel.CloseWindowCommand}"
                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
        </Grid>
    </Grid>
</Window>